package com.bskj.kuaifu.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bskj.common.bean.model.ParkingLotCustomer;
import com.bskj.common.cache.mapCache.AreaInfoCache;
import com.bskj.common.utils.StringUtils;
import com.bskj.kuaifu.service.IParkingLotCustomerService;

@Controller
@RequestMapping("/parkingLotCustomer")
public class ParkingLotCustomerController {
	@Autowired
	private IParkingLotCustomerService parkingLotCustomerService;
	
	@Autowired
	private AreaInfoCache areaInfoCache;

	/**
	 * 新增一个停车场客户
	 * 
	 * @param xmlStr
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping("add")
	public Map<String, String> add(String name,String areaCode,String stree) throws Exception {
		Map<String, String> responeMap = new HashMap<String, String>();
		
		//新增停车场。
		ParkingLotCustomer parkingLotCustomer = new ParkingLotCustomer();
		parkingLotCustomer.setName(name);
		parkingLotCustomer.setAreaCode(areaCode);
		parkingLotCustomer.setAreaName(areaInfoCache.getFullAreaName(areaCode));
		parkingLotCustomer.setStree(stree);
		parkingLotCustomer.setCreateTime(new Date());
		parkingLotCustomer.setUpdateTime(new Date());
		
		String uuid = StringUtils.getRandomWithTimestamp(20);
		parkingLotCustomer.setUuid(uuid);
		
		parkingLotCustomerService.insert(parkingLotCustomer);
		
		responeMap.put("id", parkingLotCustomer.getId() + "");
		responeMap.put("uuid", parkingLotCustomer.getUuid());
		return responeMap;
	}
}
